<?php
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------

namespace app\model;

use \think\Model;

class Shop extends Model
{
    protected $name = 'shop';
    protected $autoWriteTimestamp = true;
    protected $insert = [];
    protected $update = [];

    public function getImageAttr($value)
    {
        return is_numeric($value) ? get_file_path($value, 1) : $value;
    }


    public function category()
    {
        return $this->belongsTo(ShopCategory::class, 'category_id')
            ->bind([
                'category_name' => 'name',
            ]);
    }
}
